class Solution(object):
    def sortColors(self, nums):
        """
        :type nums: List[int]
        :rtype: void Do not return anything, modify nums in-place instead.
        """
        def partition(begin, end):
            pivot = nums[begin]
            i, j = begin, end
            while i < j:
                while i<j and nums[j]>=pivot: j-=1
                nums[i]=nums[j]
                while i<j and nums[i]<=pivot: i+=1
                nums[j]=nums[i]
            nums[i]=pivot
            return i
        def quickSort(begin, end):
            if begin>=end:
                return
            pivot = partition(begin, end)
            quickSort(begin, pivot-1)
            quickSort(pivot+1, end)
        quickSort(0, len(nums)-1)

nums = [0,1,2,0,1,2]
Solution().sortColors(nums)
print(nums)